<?php

require_once ('system/libraries/Model.php');

class UserModel extends Model {
	
	private $userID = 0;
	private $username = null;
	private $password = null;
	private $name = null;
	private $email = null;
	private $langId= 0;
	
	/**
	 * 
	 *@access public 
	 */
	function UserModel($userID = null) {
		parent::__construct ();
		if ($userID != null) {
			$queryString = "select * from users where userID=?";
			$query = $this->db->query($queryString, $userID);
			foreach ($query->result() as $row) {
				$this->setName($row->name);
				$this->setPassword($row->password);
				$this->setUserID($row->userID);
				$this->setUsername($row->username);
			}
			
			if ($this->getUserID() == 0) {
				throw new Exception("No user with id $userID");
			}
		}
	
	}
	/**
	 * @return unknown
	 */
	public function getName() {
		return $this->name;
	}
	
	/**
	 * @return unknown
	 */
	public function getPassword() {
		return $this->password;
	}
	
	/**
	 * @return unknown
	 */
	public function getUserID() {
		return $this->userID;
	}
	
	/**
	 * @return unknown
	 */
	public function getUsername() {
		return $this->username;
	}
	
	/**
	 * @param unknown_type $name
	 */
	public function setName($name) {
		$this->name = $name;
	}
	
	/**
	 * @param unknown_type $password
	 */
	public function setPassword($password) {
		$this->password = $password;
	}
	
	/**
	 * @param unknown_type $userId
	 */
	public function setUserID($userID) {
		$this->userID = $userID;
	}
	
	/**
	 * @param unknown_type $username
	 */
	public function setUsername($username) {
		$this->username = $username;
	}

	public function __toString() {
		return $this->username;
	}
}

?>
